import com.orphan.AuditMain;
import com.orphan.audit.po.Deposit;
import com.orphan.audit.po.Save;
import com.orphan.audit.service.IDepositService;
import com.orphan.audit.service.IPreDiscountService;
import com.orphan.audit.service.ISaveService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDateTime;
import java.util.List;

@SpringBootTest(classes = {AuditMain.class})
public class PreDeposit {

    @Autowired
    private IDepositService depositService;
    @Autowired
    private ISaveService saveService;
    @Autowired
    private IPreDiscountService preDiscountService;

    @Test
    public void test(){
        List<Deposit> list = depositService.findAll();
        System.out.println(list);
    }

    @Test
    public void queryDeposit(){
        Deposit deposit = depositService.queryDeposit(1l);
        System.out.println("查询结果:"+ deposit);
    }

    @Test
    public void save(){
        Save save = new Save();
        save.setTUserid(2l);
        save.setTSum(1000f);
        save.setTTime(LocalDateTime.now());
        save.setTStuff("周中伟");
        saveService.saveMoney(save);
    }


    @Test
    public void exist(){
        Integer count = depositService.exist(7l);
        System.out.println("查询结果为:"+ count);
    }

    @Test
    public void update(){
        Deposit deposit = new Deposit();
        deposit.setTTotal(4000f);
        deposit.setTBalance(4000f);
        deposit.setTUserid(2l);
        Integer count = depositService.update(deposit);
        System.out.println(count);
    }

    @Test
    public void saveFindAll(){
        List<Save> list = saveService.findAll();
        System.out.println(list);
    }

    @Test
    public void getRate(){
        float rate = preDiscountService.getRate(8100);
        System.out.println(rate);

    }
}
